package com.roncoo.education.course.service.admin;

import com.roncoo.education.common.config.ThreadContext;
import com.roncoo.education.common.core.base.Result;
import com.roncoo.education.course.dao.impl.mapper.CategoryMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.UUID;

@RestController
@RequestMapping("/course/admin/course")
public class AdminClassController {


    @Resource
    CategoryMapper categoryMapper;


    @GetMapping("createClass")
    public void createClass(String className, String desc) {
        categoryMapper.createCategory(className, UUID.randomUUID().toString(), desc);
    }


    @GetMapping("/listClass")
    public Result<List<Map<String, Object>>> listClass() {

        return Result.success(categoryMapper.getClassList());
    }


    @GetMapping("/attachClass")
    public void addCourseClass(Long courseId, Integer classId) {
        categoryMapper.addClassCourse(courseId,classId);
    }




    @GetMapping("/auth/attachUser")
    public void attachUser(String id) {
        categoryMapper.addUserCourse(ThreadContext.userId(),id);
    }


}
